As well as allowing single-line text boxes, forms also allow multiline text areas. A text area does not use the input tag; it is a pair <textarea> ... </textarea> in its own right, with the default contents going between the two tags. A text area must still have a name, but we can also specify how many rows and columns it has.
Here is the HTML code for a 40 by 4 text box with some initial default text.
<form action="http://agora.leeds.ac.uk/Perl-cgi/environment-example" method="GET"> <textarea name="review" cols=40 rows=4>I urge you to see it. </textarea> <input type="submit" value="Publish"> </form>This looks like
When the submit button is clicked the contents of the entire text box is packaged up and sent as the query string. It is at this point that things can start to go wrong. The information to the query string is sent as part of the URL, but the URL can often only be so many characters long (about two hundred) before the HTTP server chokes on information overload. This isn't very likely with the examples we've seen before now, but text areas can contain potentially unlimited amounts of text and so it starts to be a danger. The solution is to use another method to send the data.
Once again these details needn't bother us, though, because the &read_input subroutine is designed to cope with this. All we need to worry about is setting the form's method to POST, and then everything else stays the same. The resultant HTML code should look like this
<form action="http://agora.leeds.ac.uk/Perl-cgi/environment-example" method="POST"> <textarea name="review" cols=40 rows=4>I urge you to see it. </textarea> <input type="submit" value="Publish"> </form>Notice that only the method has changed from GET to POST. Everything else remains the same. Now when the URL is accessed the query string should be empty because the information is no longer sent that way. Try it:
The way to access the information is to write a CGI script which uses the &read_input subroutine. The script in ~webm/WWW/Perl/cgi-bin/ta-example is one such. Here is the HTML code for the form which accesses it, followed by the form itself.
<form action="http://agora.leeds.ac.uk/Perl-cgi/ta-example" method="POST"> <textarea name="review" cols=40 rows=4>I urge you to see it. </textarea> <input type="submit" value="Publish"> </form>
It's interesting to note that since this text is fed straight into the HTML document being generated it's actually interpreted as HTML. For a graphic illustration of this try pasting the above HTML code into the text area and submitting that.